<%@page import="model.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
	User u =new User();
//	kiem tra có phải admin không nếu khong thi redirect home
	if (!u.isAdmin((String) session.getAttribute("lv"))) {
		response.sendRedirect("../index.jsp");
	}
	National national = new National();
	Categories categories = new Categories();
	int sp = categories.getSizeDB();
	int pt = 0;
	int id = 0;
	/* get info where error */
	String n = ((String)request.getAttribute("n"));
	String nid = (String) request.getAttribute("nid");
	String p = ((String)request.getAttribute("p"));
	String en = ((String)request.getAttribute("en"));
	if(p!=null){ pt= Integer.parseInt(p);};
	if(nid!=null){ id= Integer.parseInt(nid);};
	n = (n==null)? "":n ;
	en = (en==null)? "*":en ;

%>
<title>MYFILM - Add Categories</title>
		<form action="AddCat" onsubmit="return validate(this)" method="post">
			<fieldset>
				<legend>Add Category</legend>
				<div>
					<label for="n">Categories Name: <span class="required"><%=en %></span></label>
					<input type="text" name="n" value="<%=n%>" size="20" maxlength="150" tabindex="1"/>
				</div>
				<div>
					<label for="pt">Position: <span class="required">*</span></label> 
					<select name="pt" tabindex='3'>
						<%for(int i =1; i<=(sp+1);i++){ %>
						<option value="<%=i%>" <%=(i==id)?"selected='selected'":""%>><%=i%></option>
						<%} %>
					</select>
				</div>
				<input type="hidden" name="uid" value="<%=session.getAttribute("lv")%>">
			</fieldset>
			<p>
				<input type="submit" name="submit" value="Add Cat" />
			</p>
		</form>